<?php
use think\migration\Migrator;
use think\migration\db\Column;

class CreateQasTable extends Migrator
{
    public function up()
    {
        $this->table('qas')->addColumn('question', 'text', ['comment' => '问题'])
                          ->addColumn('answer', 'text', ['comment' => '答案'])
                          ->addColumn('created_at', 'datetime', ['comment' => '创建时间', 'defaultExpress' => 'CURRENT_TIMESTAMP'])
                          ->addColumn('updated_at', 'datetime', ['comment' => '更新时间', 'updateTime' => true])
                          ->addColumn('is_published', 'tinyint', ['limit' => 1, 'default' => 0, 'comment' => '是否发布'])
                          ->save();
    }

    public function down()
    {
        $this->dropTable('qas');
    }
}
